import request from '@/utils/request'

// 获取角色列表
export const fetchRoleList = (params) => {
    return request({
        url: '/role/list',
        method: 'get',
        params: params
    })
}

// 创建角色
export const createRole = (data) => {
    return request({
        url: '/role/create',
        method: 'post',
        data: data
    })
}

// 更新角色
export const updateRole = (id, data) => {
    return request({
        url: '/role/update/' + id,
        method: 'post',
        data: data
    })
}

// 更新角色状态
export const updateRoleStatus = (id, params) => {
    return request({
        url: '/role/updateStatus/' + id,
        method: 'post',
        params: params
    })
}

// 删除角色
export const deleteRole = (data) => {
    return request({
        url: '/role/delete',
        method: 'post',
        data: data
    })
}

// 获取所有角色列表
export const fetchAllRoleList = () => {
    return request({
        url: '/role/listAll',
        method: 'get'
    })
}

// 获取角色菜单列表
export const listMenuByRole = (roleId) => {
    return request({
        url: '/role/listMenu/' + roleId,
        method: 'get'
    })
}

// 获取角色资源列表
export const listResourceByRole = (roleId) => {
    return request({
        url: '/role/listResource/' + roleId,
        method: 'get'
    })
}

// 角色分配菜单
export const allocRoleMenu = (data) => {
    return request({
        url: '/role/allocMenu',
        method: 'post',
        data: data
    })
}

// 角色分配资源
export const allocRoleResource = (data) => {
    return request({
        url: '/role/allocResource',
        method: 'post',
        data: data
    })
}
